/*
 * Copyright 2017 Zhongan.com All right reserved. This software is the
 * confidential and proprietary information of Zhongan.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Zhongan.com.
 */
package com.zhongan.gateway.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.velocity.VelocityProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver;

/**
 * 类ViewResolverConfig.java的实现描述：ViewResolver设置
 * 
 * @author wujian 2017年4月7日 上午9:50:44
 */
@Configuration
public class ViewResolverConfig {

    // VelocityLayoutViewResolver
    @Value("${velocity.layout.url}")
    private String velocityLayoutUrl;

    // 使用VelocityLayoutViewResolver替换VelocityViewResolver
    @Bean(name = "velocityViewResolver")
    public VelocityLayoutViewResolver velocityViewResolver(VelocityProperties properties) {
        VelocityLayoutViewResolver resolver = new VelocityLayoutViewResolver();
        properties.applyToViewResolver(resolver);
        resolver.setSuffix(".vm");
        resolver.setLayoutUrl(velocityLayoutUrl);
        return resolver;
    }
}
